#pragma once


#include "../apdu/apdu.def/apdu_datatypes.h"


#define MK_POSITION void *
#define MK_HANDLE	void * 


#define DEVICE_TYPE_SCSI  0
#define DEVICE_TYPE_HID	  1
#define DEVICE_TYPE_CCID  2
#define DEVICE_TYPE_TF	  3
#define DEVICE_TYPE_BLE	  4

#include "device_mutex_locker.h"

class device_base
{
public:
	device_base(void);
	virtual ~device_base(void);

public:
	virtual int open();

	virtual int close();

	virtual int set_parameter(int param, unsigned char * pValue, int valueLen);

	virtual int send_data(unsigned char * request, int request_len);

	virtual int receive_data(unsigned char * response, int *response_len);

	virtual int send_raw_data(unsigned char * cdb, int cbw_len, unsigned char * request, long request_len);

	virtual int receive_raw_data(unsigned char * cdb, int cbw_len, unsigned char * response, long *response_len);

	virtual int device_io(unsigned char * request, int request_len,unsigned char * response, int *response_len);

	virtual int set_comm_timeout(int time_out);

	virtual char * get_dev_path();

	virtual char * get_dev_name();
	
	virtual	void set_dev_name(char * devName);

	virtual int set_dev_state(enmDevState state);

	virtual enmDevState get_dev_state();

	virtual int get_device_type();
	
	virtual int dev_present();

	virtual HANDLE get_dev_os_handle();

	virtual int lock(long timeOut);

	virtual int lock(long timeOut, char * name);

	virtual int unlock();

	virtual int begin_transaction(long timeOut);

	virtual int end_transaction();

	//high speed device
	virtual int get_hs_apdu_size(int * size);

	virtual int enable_high_speed(int mode);

	virtual int crypt_with_high_speed(unsigned long algo_id, int mode, int appid, int containerId, int keyId,
		int firstPackage, unsigned char * iv, int iv_len,
		unsigned char * input, int input_len, unsigned char * output, int *output_len);

private:
	device_mutex_locker	_locker;

	device_mutex_locker	_skf_locker;
};
